Skip to content

Add update or create handle related cutomer rows in DB in contact page#560

Open
avishka-ra wants to merge 5 commits into
masterfrom
INTGRTNS-532-WHMCS-Duplicate-owner-handle-created-on-first-WHOIS-edit-instead-of-updating-existing-handle
Open

Add update or create handle related cutomer rows in DB in contact page#560
avishka-ra wants to merge 5 commits into
masterfrom
INTGRTNS-532-WHMCS-Duplicate-owner-handle-created-on-first-WHOIS-edit-instead-of-updating-existing-handle

Conversation

@avishka-ra

@avishka-ra avishka-ra commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Root cause

When getContactDetails fetches domain contacts from the OP API, the wHandles and wDomain_handle tables were never populated for that domain. As a result, when the user submitted the WHOIS edit form, updateOrCreate in Handle.php could not find an existing handle in wHandles and fell through to create a new one in OP — duplicating the owner handle instead of updating it.

Fix

Two files changed:

  • ContactController.php — added syncHandlesWithWhmcs (+ two helpers) called after fetching contacts from the API in getContactDetails:

  • Looks up the WHMCS domain and user from tbldomains

  • For each role that has both a handle ID and contact data, ensures a wHandles row exists via ensureWHandleRow and a wDomain_handle pivot row via syncDomainHandleLink

  • wHandles.type rules: Owner is always all; any OP handle shared by more than one role is also all; a handle serving exactly one non-Owner role gets that role's specific type (admin/tech/billing)

  • Existing wHandles.data is never overwritten — it may carry extensionAdditionalData set during registration

  • Type is upgrade-only (specific → all allowed; all → specific never)

Handle.php — in the updateOrCreate "no change" path (OP data matches the form, no API update needed): detects when wHandles.data is stale (e.g. written by the new sync with only basic contact fields) and refreshes it, keeping findExisting accurate on future calls.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to keep WHMCS-side handle records (wHandles and wDomain_handle) in sync with OpenProvider contact handles when viewing the contact details page, and to refresh stored handle data even when no OpenProvider-side update is required—so lookups like findExisting() stay accurate.

Changes:

  • Update Handle::updateOrCreate() to refresh wHandles.data when OpenProvider data matches the form but the local serialized Customer differs.
  • Add ContactController::syncHandlesWithWhmcs() and call it from getContactDetails() to create/link missing wHandles / wDomain_handle rows based on fetched OpenProvider contacts.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
modules/registrars/openprovider/src/Handle.php Refreshes wHandles.data when no OP-side change is needed, to prevent stale serialized Customer data.
modules/registrars/openprovider/Controllers/System/ContactController.php Adds a sync routine to backfill/link handle rows in WHMCS when contact data is fetched from OpenProvider.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread modules/registrars/openprovider/src/Handle.php Outdated
Comment thread modules/registrars/openprovider/Controllers/System/ContactController.php Outdated
Comment thread modules/registrars/openprovider/Controllers/System/ContactController.php Outdated
Comment thread modules/registrars/openprovider/Controllers/System/ContactController.php Outdated
Comment thread modules/registrars/openprovider/Controllers/System/ContactController.php Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

Comment thread modules/registrars/openprovider/src/Handle.php Outdated
Comment thread modules/registrars/openprovider/src/Handle.php Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants